Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

digest: allow separators in algorithm field #33

Merged
merged 3 commits into from
May 10, 2017

Conversation

stevvooe
Copy link
Contributor

In the past, we have had support for separators in the algorithm field
to allow parameterization of digest algorithms. A classic example is
tarsum+sha256. While this particular case is deprecated, support for
this case in the future must be allow in case we bring this back. This
will ensure that implementations these as valid digest, but correctly
report error when the algorithm is unsupported, rather than this being
treated as an invalid format.

Signed-off-by: Stephen J Day [email protected]

@vbatts
Copy link
Member

vbatts commented Apr 24, 2017

Oh interesting to bring that back. When might it be needed?

@stevvooe
Copy link
Contributor Author

Oh interesting to bring that back. When might it be needed?

In the case where we want some parameterized algorithm agility. I explained this much better in opencontainers/image-spec#654. One example was sha256+b64 (effectively, doing alternate encodings correctly). This ensures that such constructions don't create a validation error but instead have the correct "unsupported" error.

@dmcgowan
Copy link
Member

dmcgowan commented Apr 24, 2017

This regexp still differs from what we have defined in distribution, but what we defined in distribution my be too strict. Is there any reason to disallow the algorithm/component part from starting with a number?

@vbatts
Copy link
Member

vbatts commented Apr 25, 2017

cool cool. @stevvooe should this pr include a bit of docs explaining that?

@vbatts
Copy link
Member

vbatts commented Apr 25, 2017

oh i see the image-spec explanation.

@dmcgowan
Copy link
Member

Change to not allow a number as the first character should be in different PR, if we want that

@vbatts
Copy link
Member

vbatts commented Apr 25, 2017 via email

In the past, we have had support for separators in the algorithm field
to allow parameterization of digest algorithms. A classic example is
`tarsum+sha256`. While this particular case is deprecated, support for
this case in the future must be allow in case we bring this back. This
will ensure that implementations these as valid digest, but correctly
report error when the algorithm is unsupported, rather than this being
treated as an invalid format.

We also widen the character set allowed in the hex encoded portion of
the digest to allow support for future encodings that are not hex-based.

Signed-off-by: Stephen J Day <[email protected]>
@stevvooe
Copy link
Contributor Author

@vbatts Brought this into line with opencontainers/image-spec#654.

@stevvooe
Copy link
Contributor Author

@opencontainers/go-digest-maintainers PTAL

digest.go Outdated
}

// NewDigestFromEncoded returns a Digest from alg and a the encoded digest.
func NewDigestFromEncoded(alg Algorithm, hex string) Digest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename hex

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename hex

More discussion along these lines in #30, #31, and #32.

@dmcgowan
Copy link
Member

This change looks reasonable. From my understanding we are stating with this change that any given digest algorithm value can only have one valid output format, which is crucial for the usefulness of this package. The existing algorithm could then be implied to be sha256 using hex by default, such that sha256+hex is not needed, but now sha256+b64 is possible in the future without ambiguity.

Is it worth keeping deprecated functions pre-1.0 of this package? It is an easy translation to use this newer form.

We made a change to call the _hex_ portion the _encoded_ portion and
this makes a few updates to make that clearer for prospective users of
this package.

Signed-off-by: Stephen J Day <[email protected]>
@stevvooe stevvooe force-pushed the future-proof-algorithm-field branch from 0a8e2cf to 55f6758 Compare April 25, 2017 21:07
@stevvooe
Copy link
Contributor Author

Is it worth keeping deprecated functions pre-1.0 of this package? It is an easy translation to use this newer form.

We can do a full pass on that later. I think this up to the community.

@dmcgowan
Copy link
Member

dmcgowan commented Apr 27, 2017

LGTM

Approved with PullApprove

@stevvooe stevvooe force-pushed the future-proof-algorithm-field branch from d15bd73 to 678a95e Compare May 10, 2017 01:39
@stevvooe
Copy link
Contributor Author

Updated per opencontainers/image-spec#654.

@opencontainers/go-digest-maintainers PTAL

@vbatts
Copy link
Member

vbatts commented May 10, 2017

LGTM

Approved with PullApprove

1 similar comment
@dmcgowan
Copy link
Member

dmcgowan commented May 10, 2017

LGTM

Approved with PullApprove

@dmcgowan dmcgowan merged commit eaa6054 into opencontainers:master May 10, 2017
@stevvooe stevvooe deleted the future-proof-algorithm-field branch May 10, 2017 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants